// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {},

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        let _data = [
            {
                time: 1,
                rota: 12,
            }, {
                time: 1.2,
                rota: 10,
            }, {
                time: 1.4,
                rota: 8,
            }, {
                time: 1.6,
                rota: 6,
            },
        ];
        let _str = this.node.name;
        let _t;
        let _r;
        for (let i = 1; i < _data.length + 1; i++) {
            if ("sp" + i == _str) {
                _t = _data[i - 1].time;
                _r = _data[i - 1].rota;
            }
        }
        this.node.runAction(
            cc.repeatForever(
                cc.sequence(
                    cc.rotateTo(_t,-_r,),
                    cc.rotateTo(_t,0,),
                    cc.rotateTo(_t,_r,),
                    cc.rotateTo(_t,0,),
                )
            )
        )
    },

    start() {

    },

    // update (dt) {},
});
